import HttpKit from '../../utils/http-kit'

export default {
  /**
   * @description 业务员获取所有的订单编号
   * @returns {Promise<T | never>}
   */
  getAllOrderList () {
    return HttpKit.get('/books', {pageNumber: '0', pageSize: '10000'}).then(
      res => res.data
    )
  },
  /**
   * @description 业务员确定订单
   * @param order
   * @returns {Promise<T | never>}
   */
  confirmOrder (order) {
    return HttpKit.post('/book/confirm', {
      'contractId': 0,
      'customerId': order.customerId,
      'endDate': order.endDate,
      'id': order.id,
      'sellId': order.sellId,
      'spotId': order.spotId,
      'startDate': order.startDate,
      'status': order.status,
      'workOrderId': 0
    }).then(
      res => res.data
    )
  },
  /**
   * @description 业务员派发订单任务
   * @param order
   * @returns {Promise<T | never>}
   */
  assignTask (order) {
    return HttpKit.post('/book/assignTask', {
      'workOrderId': order.workOrderId,
      'contractId': order.contractId,
      'customerId': order.customerId,
      'endDate': order.endDate,
      'id': order.id,
      'sellId': order.sellId,
      'spotId': order.spotId,
      'startDate': order.startDate,
      'status': order.status
    }).then(
      res => res.data
    )
  }
}
